<template>
    <div class="work-adv-add">
        <h4 class="page-work-title"><label>添加顾问</label></h4>
        <el-form class="add-form" label-position="right" label-width="100px">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="真实姓名：" class="inline-input">
                        <el-input v-model="form.name" placeholder="请输入"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="联系电话：" class="inline-input">
                        <el-input v-model="form.mobile" placeholder="请输入"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item class="textarea-input">
                <el-input 
                    type="textarea" 
                    rows="5" 
                    v-model="form.desc"
                    placeholder="请简单介绍下您的设计师顾问，50个字以内，如头衔、参与项目等，以分号隔开换行。"></el-input>
            </el-form-item>
            <el-form-item class="upload-input">
                顾问头像
                <app-upload 
                    :action="$store.state.url.uploadImage" 
                    list-type="picture-card" 
                    :form-data="form" form-key="headimg" :max-num="1">
                </app-upload>
            </el-form-item>

            <el-button type="primary" @click="onSubmit">提交</el-button>
        </el-form>
    </div>
</template>

<script>
import {saveAdviser} from '../../../api/adviser'
import appUpload from '../../../component/appUpload'
export default {
    name: 'adviserAdd',
    components: {
        appUpload
    },
    data(){
        return {
            form: {
                headimg: '',
                name: '',
                mobile: '',
                desc: ''
            }
        }
    },
    methods: {
        onSubmit(){
            const data = Object.assign({}, this.form)
            data.designerId = localStorage.designerId
            saveAdviser(data).then(rsp => {
                if(rsp.code === 200){
                    this.$message.success('添加成功')
                    this.$router.push({name: 'myAdviserResult', params: {id: rsp.data}})
                }
            })
        }
    }
}
</script>


<style lang="less">
.work-adv-add{
    .add-form{
        padding: 30px 50px;
        .el-input__inner{
            border: none;
        }
        .inline-input{
            .el-form-item__label{
                font-size: 15px;
            }
        }
        .textarea-input{
            .el-form-item__content{
                margin-left: 0 !important;
            }
            .el-textarea__inner{
                padding: 20px 0;
                border-radius: 0;
                border-left: none;
                border-right: none;
                resize: none;
                &:focus{
                    border-color:#dcdfe6;
                }
            }
        }
        .upload-input{
            .el-form-item__content{
                margin-left: 0 !important;
            }
        }
    }
}
</style>

